component.form-validator

form-validator

Validate a form with jQuery


Policy & Newsletter

Topics

Select at least two topics you would like to receive in the newsletter.


<!-- Form -->
<form class="form-horizontal margin-none" id="validateSubmitForm" method="get" autocomplete="off">
	
	<!-- Widget -->
	<div class="widget widget-inverse">
	
		<!-- Widget heading -->
		<div class="widget-head">
			<h4 class="heading">Validate a form with jQuery</h4>
		</div>
		<!-- // Widget heading END -->
		
		<div class="widget-body">
		
			<!-- Row -->
			<div class="row">
			
				<!-- Column -->
				<div class="col-md-4">
				
					<!-- Group -->
					<div class="form-group">
						<label class="col-md-4 control-label" for="firstname">First name</label>
						<div class="col-md-8"><input class="form-control" id="firstname" name="firstname" type="text" /></div>
					</div>
					<!-- // Group END -->
					
					<!-- Group -->
					<div class="form-group">
						<label class="col-md-4 control-label" for="lastname">Last name</label>
						<div class="col-md-8"><input class="form-control" id="lastname" name="lastname" type="text" /></div>
					</div>
					<!-- // Group END -->
					
					<!-- Group -->
					<div class="form-group">
						<label class="col-md-4 control-label" for="username">Username</label>
						<div class="col-md-8"><input class="form-control" id="username" name="username" type="text" /></div>
					</div>
					<!-- // Group END -->
					
				</div>
				<!-- // Column END -->
				
				<!-- Column -->
				<div class="col-md-8">
				
					<!-- Group -->
					<div class="form-group">
						<label class="col-md-4 control-label" for="password">Password</label>
						<div class="col-md-8"><input class="form-control" id="password" name="password" type="password" /></div>
					</div>
					<!-- // Group END -->
					
					<!-- Group -->
					<div class="form-group">
						<label class="col-md-4 control-label" for="confirm_password">Confirm password</label>
						<div class="col-md-8"><input class="form-control" id="confirm_password" name="confirm_password" type="password" /></div>
					</div>
					<!-- // Group END -->
					
					<!-- Group -->
					<div class="form-group">
						<label class="col-md-4 control-label" for="email">E-mail</label>
						<div class="col-md-8"><input class="form-control" id="email" name="email" type="email" /></div>
					</div>
					<!-- // Group END -->
					
				</div>
				<!-- // Column END -->
				
			</div>
			<!-- // Row END -->
			
			<hr class="separator" />
			
			<!-- Row -->
			<div class="row uniformjs">
			
				<!-- Column -->
				<div class="col-md-4">
					<h4>Policy &amp; Newsletter</h4>
					<label class="checkbox" for="agree">
						<input type="checkbox" class="checkbox" id="agree" name="agree" />
						Please agree to our policy
					</label>
					<label class="checkbox" for="newsletter">
						<input type="checkbox" class="checkbox" id="newsletter" name="newsletter" />
						Receive Newsletter
					</label>
				</div>
				<!-- // Column END -->
				
				<!-- Column -->
				<div class="col-md-8">
					<div id="newsletter_topics">
						<h4>Topics</h4>
						<p>Select at least two topics you would like to receive in the newsletter.</p>
						<label for="topic_marketflash">
							<input type="checkbox" id="topic_marketflash" value="marketflash" name="topic" />
							Marketflash
						</label>
						<label for="topic_fuzz">
							<input type="checkbox" id="topic_fuzz" value="fuzz" name="topic" />
							Latest fuzz
						</label>
						<label for="topic_digester">
							<input type="checkbox" id="topic_digester" value="digester" name="topic" />
							Mailing list digester
						</label>
					</div>
				</div>
				<!-- // Column END -->
				
			</div>
			<!-- // Row END -->
		
			<hr class="separator" />
			
			<!-- Form actions -->
			<div class="form-actions">
				<button type="submit" class="btn btn-primary"><i class="fa fa-check-circle"></i> Save</button>
				<button type="button" class="btn btn-default"><i class="fa fa-times"></i> Cancel</button>
			</div>
			<!-- // Form actions END -->
			
		</div>
	</div>
	<!-- // Widget END -->
	
</form>
<!-- // Form END -->

Code

@import "assets/components/core/less/widgets.less";
@import "assets/components/modules/admin/ui/buttons/assets/buttons.less";
@import "assets/components/core/less/forms.less";

Usage

  1. Create a new LESS file (eg. styles.less)
  2. Copy & paste the above imports in the LESS file.
  3. Place the file in your project's document root.
  4. Load the LESS file into the <head> section of your HTML document, before any JavaScript files:

    <link type="stylesheet/less" href="styles.less" />

    NOTE  All the styles from the CORE package also need to be imported in this file, before the component imports.

  5. If you'd like to include other components on the same page, don't create multiple LESS files, but add all the imports in one file. You can create a LESS file for each page with just the resources used for that specific page, or you could create and use a single LESS file for the entire project.
  6. In production, compile the LESS file and use the resulting minified CSS file in the HTML document.

Scripts

BODY You should include the following scripts at the end of the HTML document, right before the closing </body> tag.

<script src="assets/components/modules/admin/forms/validator/assets/lib/jquery-validation/dist/jquery.validate.min.js?v=v1.2.3"></script>
<script src="assets/components/modules/admin/forms/validator/assets/custom/form-validator.init.js?v=v1.2.3"></script>